//
// Created by lightning on 2021/7/10.
//

#include "Widgets.hpp"

namespace RoboPioneers::Lidar::UI
{
    bool Widgets::GrabPicture()
    {
        if(!Device.grab()) return false;

        Device >> Picture;
        cv::resize(Picture,Picture,cv::Size(Width,Height));
        return true;
    }

    bool Widgets::MixPicture(cv::Mat &output, int x, int y)
    {
        
        if(Picture.empty()) return false;

        cv::Mat roi = output(cv::Rect (x,y,Picture.cols,Picture.rows));
        // 交运算保证在图像范围内
        Picture.copyTo(roi);
        return true;
    }
}